<?php
namespace app\app\util;
use think\Request;
use think\cache\driver\Redis;

define('STAR_CARD','ft:user_card:id=');

class CardUtils{

	//用户已有球星卡id
	public static function getUserStarCard($user_id,$card_id='')
	{
		$redis = new Redis(['host'=>config('REDIS_HOST'),'password'=>config('REDIS_AUTH')]);
		if($card_id == ''){
			//查询
			return $redis->smembers(STAR_CARD.$user_id);
		}else{
			//添加
			return $redis->sadd(STAR_CARD.$user_id,$card_id);
		}
	}

	//减少用户已有球星卡id
	public static function sremUserStarCard($user_id,$card_id)
	{
		$redis = new Redis(['host'=>config('REDIS_HOST'),'password'=>config('REDIS_AUTH')]);
		return $redis->srem(STAR_CARD.$user_id,$card_id);
	}	

}